/*
 * Copyright (c) 2022, IMMORTA Inc.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 *
 * - Redistributions of source code must retain the above copyright notice, this list
 *   of conditions and the following disclaimer.
 *
 * - Redistributions in binary form must reproduce the above copyright notice, this
 *   list of conditions and the following disclaimer in the documentation and/or
 *   other materials provided with the distribution.
 *
 * - Neither the name of IMMORTA Inc. nor the names of its
 *   contributors may be used to endorse or promote products derived from this
 *   software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef PMC_DRV_H
#define PMC_DRV_H

/*!
 * @file pmc_drv.h
 * @brief This file declares pmc driver interfaces
 */

/*!
 * @addtogroup pmc_drv
 * @{
 */

/*******Includes***************************************************************/
#include <stdbool.h>
#include "device_registers.h"

/*******Definitions************************************************************/

/*!
 * @brief Power Modes
 */
typedef enum {
    POWER_MODE_STOP = 1U            /*!< Power mode is STOP */
} pmc_power_mode_t;

/*!
 * @brief LVD Level
 */
typedef enum {
    LVD_LEVEL_HIGH   = 0U,           /*!< LVD high level */
    LVD_LEVEL_LOW    = 1U            /*!< LVD low level */
} pmc_lvd_level_t;


/*******APIs*******************************************************************/
#if defined(__cplusplus)
extern "C" {
#endif

/*!
 * @brief System enter power mode
 *
 * @param[in] powerMode: Power mode defined in pmc_power_mode_t
 * @return None
 */
void PMC_EnterPowerMode(pmc_power_mode_t powerMode);

/*!
 * @brief LVD level select and enable
 *
 * @param[in] lvdLevel: LVD level defined in pmc_lvd_level_t
 * @param[in] moduleEn: Enable State
 *            - true: Enable the LVD module
 *            - false: Disable the LVD module
 * @param[in] intEn: Enable State
 *            - true: Enable the LVD interrupt
 *            - false: Disable the LVD interrupt
 * @return None
 */
void PMC_ConfigLvd(pmc_lvd_level_t lvdLevel, bool moduleEn, bool intEn);

/*!
 * @brief Get Low Voltage Detet or Wakeup Flag
 *
 * @param[in] flag: flag defined in pmc_flag_t
 * @return  flag status:
 *          - true: flag detected
 *          - false: flag not detected
 */
bool PMC_GetFlag(pmc_flag_t flag);

/*!
 * @brief Clear low voltage detet or Wakeup flag
 *
 * @param[in] flag: flag defined in pmc_flag_t
 * @return None
 */
void PMC_ClearFlag(pmc_flag_t flag);

/*!
 * @brief Set wakeup source enable
 *
 * @param[in] wakeupSource: Power mode defined in pmc_wakeup_source_t
 * @param[in] enable: Enable State
 *            - true: Enable wake up source
 *            - false: Disable wake up source
 * @return None
 */
void PMC_SetWakeupEnable(pmc_wakeup_source_t wakeupSource, bool enable);

/*!
 * @brief NMI interrupt enable
 *
 * @param[in] enable: Enable State
 *            - true: Enable the NMI interrupt
 *            - false: Disable the NMI interrupt
 * @return None
 */
void PMC_SetNmiIntEnable(bool enable);

#if defined(__cplusplus)
}
#endif

/*! @} */

#endif /* PMC_DRV_H */

/*******EOF********************************************************************/
